<template>
  <div class="base-container">
    <!-- <t-form ref="form" :data="queryParams" label-width="80"
      @submit="() => { this.pagination.current = 1; this.queryParams.pageNum = 1; this.getList() }">
      <t-row style="border-bottom: 1px solid #E5E6EB;margin-bottom: 10px">
        <t-col :span="11" class="query-form-inline">
          <t-form-item label="业务名称" name="businessName">
            <t-input v-model="queryParams.businessName" clearable placeholder="请输入项目名称" style="width: 240px" />
          </t-form-item>
          <t-form-item label="业务类型" name="approveType">
            <t-select style="width: 240px" clearable v-model="queryParams.approveType"
              :options="dict.type.kjpt_approve_type">
            </t-select>
          </t-form-item>
        </t-col>
        <t-col :span="1" class="operation-container">
          <t-button theme="primary" type="submit"> 查询</t-button>
          <t-button theme="default" variant="outline" type="reset">重置</t-button>
        </t-col>
      </t-row>
    </t-form> -->
    <t-table rowKey="id" :data="data" :columns="columns" hover :pagination="pagination" :loading="dataLoading">
      <template #[`platformInfo.name`]="{ row }">
        <t-link v-if="row.approveType == 1"
          @click="dialog.objId = row.platformInfo.id; dialog.header = row.platformInfo.name; dialog.open_project_detail = true"
          hover="color" theme="primary">{{ row.platformInfo.name }}</t-link>
        <t-link v-else
          @click="dialog.objId = row.businessId; dialog.header = row.platformInfo.name; dialog.open_score_detail = true"
          hover="color" theme="primary">{{ row.platformInfo.name }}</t-link>
      </template>
      <template #[`platformInfo.platformStatus`]="{ row }">
        <t-tag class="cursor-pointer" :theme="handleTheme(row.platformInfo.platformStatus, dict.type.platform_status)"
          variant="light">
          {{ row.platformInfo.platformStatus | filterByDict(dict.type.platform_status) }}
        </t-tag>
      </template>
      <template #approveType="{ row }">
        {{ row.approveType | filterByDict(dict.type.kjpt_approve_type) }}
      </template>
      <template #op="{ row }">
        <t-button v-if="row.approveType == 1" size="small"
          @click="dialog.objId = row.platformInfo.id; dialog.header = row.platformInfo.name; dialog.open_project_detail = true"
          variant="text" class="t-button-link">
          <t-icon name="info-circle" slot="icon" />
          详情
        </t-button>
        <t-button v-else size="small"
          @click="dialog.objId = row.businessId; dialog.header = row.platformInfo.name; dialog.open_score_detail = true"
          variant="text" class="t-button-link">
          <t-icon name="info-circle" slot="icon" />
          详情
        </t-button>
        <t-button @click="dialog.row = row; dialog.open = true" size="small" variant="text" class="t-button-link">
          <t-icon name="edit-1" slot="icon" />
          审批
        </t-button>
      </template>
    </t-table>
    <platform-my-detail-dialog :header="dialog.header" :objId="dialog.objId" :visible.sync="dialog.open_project_detail"
      v-if="dialog.open_project_detail"></platform-my-detail-dialog>
    <platform-score-detail-dialog :header="dialog.header" :objId="dialog.objId" :visible.sync="dialog.open_score_detail"
      v-if="dialog.open_score_detail"></platform-score-detail-dialog>
    <approve-info :visible.sync="dialog.open" @reload="getList()" :row="dialog.row" v-if="dialog.open"></approve-info>

  </div>
</template>

<script>
import approveInfo from "@/pages/kjpt/approve/components/approve-info.vue";
import PlatformMyDetailDialog from "@/pages/kjpt/platform/components/platform-my-detail-dialog.vue";
import PlatformScoreDetailDialog from "@/pages/kjpt/platform/components/platform-score-detail-dialog.vue";

export default {
  name: "approve-my",
  dicts: ["approve_status", "sf_project_status", "platform_status", "kjpt_approve_type"],
  components: {
    PlatformMyDetailDialog,
    PlatformScoreDetailDialog,
    approveInfo,
  },
  data () {
    return {
      dialog: {
        open: false,
        header: "",
        row: {},
        data: {},
        open_project_detail: false,
        open_outline_detail: false,
        open_score_detail: false,
        objId: 0,
      },
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        approveType: '',
        businessName: '',
      },
      data: [],
      columns: [
        {
          colKey: "platformInfo.name",
          title: "平台名称",
          align: "center",
          // ellipsis: true,
          width: 220,
        },
        {
          colKey: "platformInfo.platformStatus",
          title: "平台状态",
          align: "center",
          ellipsis: true
        },
        // {
        //   colKey: "businessName",
        //   title: "业务名称",
        //   align: "center",
        //   ellipsis: true
        // },
        {
          colKey: "approveType",
          title: "审批业务类型",
          align: "center",
        },
        {
          colKey: "platformInfo.declareDeptName",
          title: "填报单位",
          align: "center",
        },
        {
          colKey: "createTime",
          title: "创建时间",
          align: "center",
          width: 200
        },
        {
          colKey: "op",
          title: "操作",
          align: "center",
          width: 200
        },
      ],

      dataLoading: false,
      pagination: {
        current: 1,
        pageSize: 10,
        total: 0,
        showPageSize: true,
        pageSizeOptions: [10, 20, 30, 50],
        showFirstAndLastPageBtn: false,
        onChange: (pageInfo) => {
          Object.assign(this.pagination, pageInfo)
          this.queryParams.pageNum = pageInfo.current || 1;
          this.queryParams.pageSize = pageInfo.pageSize;
          this.getList()
        },
      },
    }
  },
  async created () {
    this.getList()
  },
  methods: {
    getList () {
      this.dataLoading = true;
      this.$api.kjpt.approve.myApproveList(this.queryParams).then(response => {
        this.pagination.total = response.total;
        this.data = response.rows;
        this.dataLoading = false;
      }).catch((e) => {
        this.dataLoading = false;
        this.$message.error(e.toString());
      });
    },

  },
}
</script>

<style scoped></style>
